tomcat 安装

        tomcat 官网

        下载

1
2
[root@192 ~]# cd /usr/local/src
[root@192 src]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.0.M19/bin/apache-tomcat-9.0.0.M19.tar.gz

        解压

1
2
3
4
[root@192 src]# tar zxf apache-tomcat-9.0.0.M19.tar.gz
[root@192 src]# mv apache-tomcat-9.0.0.M19 /usr/local/tomcat
[root@192 src]# cp -pv /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
"/usr/local/tomcat/bin/catalina.sh" -> "/etc/init.d/tomcat"

        编辑配置文件

1
[root@192 src]# vim /etc/init.d/tomcat

        从第二行加如下配置

1
2
3
4
5
6
#chkconfig: 2345 63 37
#description: tomcat server init script
#Source Function Library
./etc/init.d/functions
JAVA_HOME=/usr/local/jdk1.8.0_111
CATALINA_HOME=/usr/local/tomcat

        保存该文件,然后把 tomcat 加入服务列表里面。

1
2
3
4
5
6
7
8
9
10
11
[root@192 src]# chmod 755 /etc/init.d/tomcat
[root@192 src]# chkconfig --add tomcat
[root@192 src]# chkconfig tomcat on
[root@192 src]# service tomcat start
/etc/init.d/tomcat: line 5: ./etc/init.d/functions: Permission denied
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk1.8.0_111
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

        检测是否启动

1
[root@192 src]# ps aux | grep tomcat

        在浏览器上输入 http://192.168.0.73:8080 可以看到 tomcat 的欢迎页。